<%@ page import="java.util.Date" %>
<%@ page import="com.bilibili.java.bookpage.bean.Commodity" %>
<%@ page import="java.util.List" %>
<%@ page import="com.bilibili.java.books.bean.User" %>
<%@ page import="com.bilibili.java.books.util.Footet" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="J54Books/css/homepage.css" />
<script type="text/javascript">
	
window.onload=function(){
	
	<%User u=(User)request.getAttribute("User");
	
	if(u.getAccount()!=null&&u.getPhone()!=null){
		
	%>
		
		
		var str=document.getElementById("dates").innerHTML;
		<%if(u.getNickname()!=null){%>
	
		str=str.replace(str,"欢迎您,<%=u.getNickname()%>");
		
		<%}else{%>
		
		str=str.replace(str,"欢迎您,<%=u.getPhone()%>");
		
		<%}%>
		
		document.getElementById("dates").innerHTML=str;
		
		
		var strs=document.getElementById("register_a").innerHTML;
		
		strs=strs.replace(strs,"退出");
		
		document.getElementById("register_a").innerHTML=strs;
		
		
		var registera= document.getElementById("register_a");
		
		registera.setAttribute("href","/J54Books/accessHomePagea");
		
		var logina= document.getElementById("login_a");
		logina.setAttribute("href","javascript:void(0)");
		
		var cart=document.getElementsByClassName("cart")[0];
		cart.style.display="block";
		var cart1=document.getElementsByClassName("cart")[1];
		cart1.style.display="block";
	<%
	}
	%>

	
}
</script>
</head>
<body>
	
	<div class="Headlines">
		<div class="Navigation">
			<div class="Navigation_One">
				<a id="login_a" class="login" href="/J54Books/J54Books/jsp/login.jsp" >
					<span id="dates">你好，请登录</span>
				</a>
				<a class="cart" href="/J54Books/shoppingCart?id=${User.id }">
					购物车
				</a>
				<a class="cart" href="/J54Books/shoppingCart?id=${User.id }">个人中心</a>
				<a id="register_a" class="register" href="/J54Books/J54Books/jsp/register.jsp">
					注册
				</a>
			</div>
		
		
		</div>
	
	</div>
	<div class="bookspage">
	
		
		<%Footet<Commodity> footet = (Footet<Commodity>)request.getAttribute("footet");
		
		
	    int	count=0;
	    for(Commodity comm :footet.getList()) {
			
	     %>
			<div id="<%=comm.getId() %>" class="books" style="<%if(count%4==0){%>clear:left<% }    %>">
				<a href="<%=request.getContextPath()%>/bookOrder?userId=<%=u.getId() %>&bookId=<%=comm.getId()%>">
					<div class="picture"><img src="/J54Books<%=comm.getDefaultPicUrl()%>"/></div>
					<div class="note">商品名：<%=comm.getGoodsName()%><br/>作者：<%=comm.getWriter() %>&nbsp;价格：<span><%=comm.getCost() %></span></div>
				</a>
			</div>
		<%
		count++;
		
	   	}
			
		%>
		
	
		<div class="pagination">
			当前第<%=footet.getPagination() %>页,共<%=footet.getPageCount() %>页;
			<%if(footet.getPagination()>1){ %>
			<a href="/J54Books/accessHomePage">首页</a>
			
			<a href="/J54Books/accessHomePage?pagination=<%=footet.getPagination()-1%>">上一页</a>
			<%} %>
			<%if(footet.getPagination()<footet.getTotalRecord()){ %>
			<a href="/J54Books/accessHomePage?pagination=<%=footet.getPagination()+1%>">下一页</a>
			
			<a href="/J54Books/accessHomePage?pagination=<%=footet.getTotalRecord()%>">尾页</a>
			<%} %>
		</div>
	</div>
	
	
</body>
</html>